﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RegOnline.RegOnlineService;

namespace RegOnline
{
    public class AppUser
    {
        private Prepod p;
        private Student s;

        private static whoisuser tip;

        public string Fio
        {
            get
            {
                Person ps = new Person();

              if (tip == whoisuser.prepod) ps = p.person;
              if (tip == whoisuser.student) ps =  s.person;

              return ps.FirstName + " " + ps.LastName[0]+". "+ ps.Patronymic[0]+".";
            }
        }
        


        private enum whoisuser
        {
            prepod, student
        } ;

        public int IdUser
        {
            get
            {

                if (tip == whoisuser.prepod) return p.Idprep;
                if (tip == whoisuser.student) return s.Idstud;
                return 100;
               
            }
        }

        public void SetUser(Object u)
        {
            if (u is Prepod)
            {
                p = u as Prepod;
                tip = whoisuser.prepod;

            }
            if (u is Student)
            {
                s = u as Student;
                tip = whoisuser.student;
            }

        }

        /// <summary>
        /// Использовать только если уверены что получаете точно студента
        /// </summary>
        /// <returns></returns>

        public Student GetAsStudent()
        {
            return s;
        }
    }

}
